package encomendaFacil.impl;

import java.util.List;

import org.apache.http.NameValuePair;
import org.junit.Assert;
import org.junit.Test;

public class ServiceTest {

	private static final String URL = "http://m.correios.com.br/movel/sro.do";
	
	@Test
	public void post(){
		String page = Service.getInstance().getPageContent(URL);
		Assert.assertNotNull(page);
		Assert.assertTrue(page.contains("200"));
		
		String trackingCode = "RC089391194HK";
		
		String responsePage = Service.getInstance().sendPost(trackingCode);
		Assert.assertNotNull(responsePage);
		Assert.assertTrue(responsePage.contains("200"));

	}
	
	@Test
	public void get(){
		String page = Service.getInstance().getPageContent(URL);
		Assert.assertNotNull(page);
		Assert.assertTrue(page.contains("200"));

	}
	
	@Test
	public void getParams(){
		String page = Service.getInstance().getPageContent(URL);
		Assert.assertNotNull(page);
		Assert.assertTrue(page.contains("200"));

		String trackingCode = "AA987654321BR";
		
		List<NameValuePair> params = Service.getInstance().getFormParams(page, trackingCode);
		Assert.assertNotNull(params);
		Assert.assertTrue(params.size() == 2);
	}
}
